package com.hejia.alauda.entity;

import java.util.Date;

import javax.persistence.Column;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

/**
 * 
 * 消息实体
 *
 *
 * Created by showone on 2014 下午3:56:25.
 *
 * @Copyright: 2014 www.hejiajinrong.com All rights reserved.
 */
@JsonIgnoreProperties(value = { "message", "deleteFlag", "receiver" })
public class Message extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	public static final String MESSAGE_TYPE_SYSTEM = "S";
	public static final String MESSAGE_TYPE_USER = "U";
	
	/**
	 * 消息类别：红包消息
	 */
	public static final String CATEGORY_BONUS = "红包消息";
	
	/**
	 * 消息类别：交易消息
	 */
	public static final String CATEGORY_TRADE = "交易消息";

	@Column
	private User receiver;// 接收人

	@Column
	private SystemMessage message;// 系统消息

	@Column(length = 1)
	private String type;// 消息类型:S,系统消息；U,用户消息
	
	@Column
	private String category; // 消息类别

	@Column
	private String title;// 标题

	@Column
	private String content;// 消息内容

	@Column
	private String url;// url地址
	
	@Column
    private String openAppPage; // 打开App页面

	@Column
	private Boolean readFlag; // 已读标志

	@Column
	private Boolean deleteFlag; // 删除标志
	
	@Column
	protected Date sendTime;// 发送时间

	protected String receiverMobile;// 接收人手机

	public User getReceiver() {
		return receiver;
	}

	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Boolean getReadFlag() {
		return readFlag;
	}

	public void setReadFlag(Boolean readFlag) {
		this.readFlag = readFlag;
	}

	public SystemMessage getMessage() {
		return message;
	}

	public void setMessage(SystemMessage message) {
		this.message = message;
	}

	public Boolean getDeleteFlag() {
		return deleteFlag;
	}

	public void setDeleteFlag(Boolean deleteFlag) {
		this.deleteFlag = deleteFlag;
	}

	public String getReceiverMobile() {
		if (receiver == null) {
			return "";
		}
		
		receiverMobile = receiver.getMobile();
		return receiverMobile;
	}

	public void setReceiverMobile(String receiverMobile) {
		this.receiverMobile = receiverMobile;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	public String getOpenAppPage() {
		return openAppPage;
	}

	public void setOpenAppPage(String openAppPage) {
		this.openAppPage = openAppPage;
	}

	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}
	
}
